package com.ruoyi.sqlbuilder.execute.relation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @ClassName: MysqlToKbColumnType
 * @Description: mysql 对应 瀚高数据库字段类型
 * @Author: Yanzy
 * @Data: 2021/5/13 14:27
 * @Source: 1.0
 */
public class MysqlToHgColumnType {

    private static Map<String, String> relation = new ConcurrentHashMap<>();

    static {
        //  mysql字段类型 --> 字段类型
        relation.put("bigint", "INT8");
        relation.put("blob", "CLOB");
        relation.put("char", "VARCHAR");
        relation.put("date", "TIMESTAMP");
        relation.put("datetime", "TIMESTAMP");
        relation.put("decimal", "DOUBLE PRECISION");
        relation.put("double", "DOUBLE PRECISION");
        relation.put("float", "FLOAT4");
        relation.put("int", "INT4");
        relation.put("longblob", "CLOB");
        relation.put("longtext", "TEXT");
        relation.put("mediumint", "int4");
        relation.put("mediumtext", "TEXT");
        relation.put("smallint", "INT2");
        relation.put("text", "TEXT");
        relation.put("mediumblob", "CLOB");
        relation.put("time", "TIMESTAMP");
        relation.put("timestamp", "TIMESTAMP");
        relation.put("tinyblob", "CLOB");
        relation.put("tinyint", "INT2");
        relation.put("tinytext", "TEXT");
        relation.put("varchar", "VARCHAR");
        relation.put("year", "TIMESTAMP");
    }

    /**
     * 获取字段类型对应转换
     * @param type mysql字段类型
     * @return 字段类型
     */
    public static String getRelationType(String type) {
        return relation.get(type.toLowerCase());
    }
}
